/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 * Only for standalone Pcp. Has 2 path fields( ob, meta)
 * The dataloader for Pcp standalone.
 * @Original Author: jin Chen
 * @date: Apr 23, 2004$
 * @version: 1.0
 */
package edu.psu.geovista.app.dataloader;

import edu.psu.geovista.app.dataloader.v1.DataLoaders;
import edu.psu.geovista.app.dataloader.v1.actions.ActionManager;
import edu.psu.geovista.app.dataloader.v1.components.PcpDataLoader;
import edu.psu.geovista.app.dataloader.v1.gui.ChooseDataPane;
import edu.psu.geovista.app.dataloader.v1.gui.PathsPane;
import edu.psu.geovista.ui.dataloader.common.FileLoadingPane;

import javax.swing.*;

public class StandAlonePcpDataLoader extends DataLoaders {

    public StandAlonePcpDataLoader() {
        super();
        String[] names={PcpDataLoader.ObservationFile ,PcpDataLoader.ObMetaFile };
        this.pcpload.setPathNames(names);

    }

     public PathsPane getPathsPane() {

        if (this.pathPane==null) {
            //JPanel p=new JPanel();
            PathsPane p=new SpathPane(this);
            p.setButtonAction(Btn_L,this.getAction(ActionManager.Act_ShowChooseData),"Back<");
            p.setButtonAction(Btn_M,this.getAction(ActionManager.Act_SelectAttrs),"Next>" );
            p.setButtonAction(Btn_R,this.getAction(ActionManager.Act_AutoSelectLoad),"Finish");
            pathPane=p;

        }
        if(this.wizardData.isLoadPcpdata()&&this.wizardData.isLoadTsdata()){
            pathPane.showPcpTs();
        }
        else if(this.wizardData.isLoadPcpdata()&&!this.wizardData.isLoadTsdata()){
              pathPane.showPcpOnly();
        }
        else if(!this.wizardData.isLoadPcpdata()&&this.wizardData.isLoadTsdata()){
               pathPane.showTsOnly();
        }
        return  pathPane;

    }
    public ChooseDataPane getChooseDataPane() {

        if (this.chooseDataPane==null) {
            //JPanel p=new JPanel();
            ChooseDataPane p=new ChooseOneDataPane(this);
            p.setButtonAction(Btn_L,this.getAction(ActionManager.Act_BackChooseData),"Back<");
            p.setButtonAction(Btn_M,this.getAction(ActionManager.Act_SetPath),"Next>" );
            p.setButtonAction(Btn_R,this.getAction(ActionManager.Act_AutoChooseLoad),"Finish");
            chooseDataPane=p;

        }

        return  chooseDataPane;

    }
    class SpathPane extends PathsPane{
        public SpathPane(DataLoaders dataloader) {
            super(dataloader);
        }
        protected  FileLoadingPane getPcpPane(){
            // 
           /* FileLoadingPane pcpPathPane = this.pcpload.getDataPathPane();
            /*Properties paths = pcpPathPane.getFileLoaderValues();

            // 
            String[] names={PcpDataLoader.ObservationFile ,PcpDataLoader.ObMetaFile };
            FileLoadingPane pcppath=new FileLoadingPane(names);
            // 
            String  obpath = (String) paths.get(PcpDataLoader.ObservationFile);
            pcppath.setFileLoaderValue(PcpDataLoader.ObservationFile,obpath );
            String  metapath = (String) paths.get(PcpDataLoader.ObMetaFile);
            pcppath.setFileLoaderValue(PcpDataLoader.ObMetaFile,metapath );

            //FileLoadingPane pcppath=this.pcpload.getDataPathPane();
             TitledBorder pcpBorder = new TitledBorder("Pcp data paths");
             pcpBorder.setTitleColor(Color.BLUE );
             pcppath.setFileSrcBorder(pcpBorder);
             return pcppath;*/
            return super.getPcpPane();
        }

    }

    class ChooseOneDataPane extends ChooseDataPane{
        public ChooseOneDataPane(DataLoaders d) {
            super(d);
            // 
            ButtonGroup bg=new ButtonGroup();
            bg.add(pcp);
            bg.add(ts);

        }
        /*public void setPcpDataLoad(boolean load){
            super.setPcpDataLoad(load);
            ts.setSelected(!load);
            //pcp.setSelected(load);
        }
        public void setTsDataLoad(boolean load){
            super.setTsDataLoad(load);
            pcp.setSelected(!load);
        }*/
    }

}
